<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1" xml:lang="en">
  <title id="gj143896">pg_database</title>
  <body>
    <p>The <codeph>pg_database</codeph> system catalog table stores information about the available
      databases. Databases are created with the <codeph>CREATE DATABASE</codeph> SQL command. Unlike
      most system catalogs, <codeph>pg_database</codeph> is shared across all databases in the
      system. There is only one copy of <codeph>pg_database</codeph> per system, not one per
      database.</p>
    <table id="gj143898">
      <title>pg_catalog.pg_database</title>
      <tgroup cols="4">
        <colspec colnum="1" colname="col1" colwidth="131pt"/>
        <colspec colnum="2" colname="col2" colwidth="86pt"/>
        <colspec colnum="3" colname="col3" colwidth="85pt"/>
        <colspec colnum="4" colname="col4" colwidth="147pt"/>
        <thead>
          <row>
            <entry colname="col1">column</entry>
            <entry colname="col2">type</entry>
            <entry colname="col3">references</entry>
            <entry colname="col4">description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry colname="col1">
              <codeph>datname</codeph>
            </entry>
            <entry colname="col2">name</entry>
            <entry colname="col3"/>
            <entry colname="col4">Database name.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>datdba</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_authid.oid</entry>
            <entry colname="col4">Owner of the database, usually the user who created it.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>encoding</codeph>
            </entry>
            <entry colname="col2">int4</entry>
            <entry colname="col3"/>
            <entry colname="col4">Character encoding for this database.
                <codeph>pg_encoding_to_char()</codeph> can translate this number to the encoding
              name.</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>datcollate</codeph></entry>
            <entry colname="col2">name</entry>
            <entry colname="col3"/>
            <entry colname="col4"><codeph>LC_COLLATE</codeph> for this database.</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>datctype</codeph></entry>
            <entry colname="col2">name</entry>
            <entry colname="col3"/>
            <entry colname="col4"><codeph>LC_CTYPE</codeph> for this database.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>datistemplate</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">If true then this database can be used in the
                <codeph>TEMPLATE</codeph> clause of <codeph>CREATE DATABASE</codeph> to create a new
              database as a clone of this one.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>datallowconn</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">If false then no one can connect to this database. This is used to
              protect the <codeph>template0</codeph> database from being altered.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>datconnlimit</codeph>
            </entry>
            <entry colname="col2">int4</entry>
            <entry colname="col3"/>
            <entry colname="col4">Sets the maximum number of concurrent connections that can be made
              to this database. <codeph>-1</codeph> means no limit.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>datlastsysoid</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3"/>
            <entry colname="col4">Last system OID in the database.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>datfrozenxid </codeph>
            </entry>
            <entry colname="col2">xid</entry>
            <entry colname="col3"/>
            <entry colname="col4">All transaction IDs (XIDs) before this one have been replaced with
              a permanent (frozen) transaction ID in this database. This is used to track whether
              the database needs to be vacuumed in order to prevent transaction ID wraparound or to
              allow pg_clog to be shrunk. It is the minimum of the per-table
                <i>pg_class.relfrozenxid</i> values.</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>datminmxid</codeph></entry>
            <entry colname="col2">xid</entry>
            <entry colname="col3"/>
            <entry colname="col4">A <i>Multixact ID</i> is used to support row locking by multiple
              transactions. All multixact IDs before this one have been replaced with a transaction
              ID in this database. This is used to track whether the database needs to be vacuumed
              in order to prevent multixact ID wraparound or to allow <codeph>pg_multixact</codeph>
              to be shrunk. It is the minimum of the per-table <i>pg_class.relminmxid</i>
              values.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>dattablespace</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_tablespace.oid</entry>
            <entry colname="col4">The default tablespace for the database. Within this database, all
              tables for which <i>pg_class.reltablespace</i> is zero will be stored in this
              tablespace. All non-shared system catalogs will also be there.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>datacl</codeph>
            </entry>
            <entry colname="col2">aclitem[]</entry>
            <entry colname="col3"/>
            <entry colname="col4">Database access privileges as given by <codeph>GRANT</codeph> and
                <codeph>REVOKE</codeph>.</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </body>
</topic>
